﻿
ol.control.AJRDWDH = function (options) {
    options = options || {};
    var element = document.createElement('div');
    if (options.target) {
        element.className = options.className || "ol-legend ajrcontrol";
    } else {
        element.className = (options.className || "ol-legend ajrcontrol")
          + " ol-unselectable ol-control ol-collapsed"
          + (options.collapsible === false ? ' ol-uncollapsible' : '');
        // Show on click
        var button = document.createElement('button');
        button.setAttribute('type', 'button');
        button.setAttribute('style', 'display: none');

        button.addEventListener('click', function () {
            element.classList.toggle('ol-collapsed');
        });
        element.appendChild(button);
        // Hide on click
        button = document.createElement('button');
        button.setAttribute('type', 'button');
        button.className = 'ol-closebox';
        button.addEventListener('click', function () {
           
            removeAll();
        });
        element.appendChild(button);
    }
    // The legend
    this._imgElement = document.createElement('div');
    this._imgElement.className = 'ol-legendImg';
    element.appendChild(this._imgElement);

    ol.control.Control.call(this, {
        element: element,
        target: options.target
    });
    this._rows = [];
    this.set('size', options.size || [40, 25]);
    this.set('margin', options.margin === 0 ? 0 : options.margin || 10);
    this.set('title', options.title || '');
    // Set the style
    this._style = options.style;
    if (options.collapsed === false) this.show();
    this.refresh();
};
ol.inherits(ol.control.AJRDWDH, ol.control.Control);

ol.control.AJRDWDH.prototype.setMap = function (map) {
    
   
    ol.control.Control.prototype.setMap.call(this, map);
    
};

ol.control.AJRDWDH.prototype.refresh = function () {

    var map = this.getMap();
    var self = this;
    var table = this._imgElement

    table.innerHTML = '';

    var width = this.get('size')[0] + 2 * this.get('margin');
    var height = this.get('size')[1] + 2 * this.get('margin');
    
    var a = document.createElement('a');

    a.setAttribute('href', '#');
    a.textContent = '单位胜利'
   
    table.appendChild(a);

    a = document.createElement('a');
    a.setAttribute('href', '#');

    a.textContent = '华北'

    table.appendChild(a);

};

/** Show control
 */
ol.control.AJRDWDH.prototype.show = function () {
    this.element.classList.remove('ol-collapsed');
};
/** Hide control
 */
ol.control.AJRDWDH.prototype.hide = function () {
    this.element.classList.add('ol-collapsed');
};
/** Toggle control
 */
ol.control.AJRDWDH.prototype.toggle = function () {
    this.element.classList.toggle('ol-collapsed');
};
 